package com.xhxg.service.advice;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//注解方式配置AOP
@Aspect
@Component
public class AdviceAnnon {
    @Pointcut("execution( * com.xhxg.dao.impl.CustomerDaoImpl.*(..))")
    public void pointcut(){} //切点
    @Before("pointcut()")   //前置通知，
    public void before(JoinPoint joinPoint){
        System.out.println("前置通知...");
    }

    @After("pointcut()")    //后置通知
    public void after(){
        System.out.println("后置通知.");
    }

    @Around("pointcut()")   //环绕通知，
    public Object around(ProceedingJoinPoint point) throws Throwable{
        System.out.println("环绕通知前...");
        Object object = point.proceed();//调用目标方法
        System.out.println("环绕通知后.");
        return object;
    }

}